package com.ash.test.aop;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ash.aop.IArithmetic;

public class MySpringTestAspect {

	@Test
	public void test() {
		ApplicationContext ac = new ClassPathXmlApplicationContext(new String[] { "beans-aop.xml" });

		// 这里必须强转成接口类，强转成 Arithmetic会报错
		IArithmetic bean = (IArithmetic) ac.getBean("arithmetic");
		System.out.println(bean.add(2, 3));

		System.out.println(bean.minus(5, 3));
		
		//异常通知的测试案例
		// bean.div(100, 0);

		bean = (IArithmetic) ac.getBean("secondArithmetic");
		System.out.println(bean.add(2, 7));

	}

}
